<?php
namespace Home\Widget;
use Think\Controller;
class ArticleWidget extends Controller {
	function category($id,$t,$n =8){
        $c = D("category");
    	$items = $c->page('1,'.$n)->select();
    	// echo ($cao);
    	//dump($items);
    	$this->assign('items',$items);
		$this->display('Widget:category_'.$t);
	}
	public function essays(){
    	
        $a = D("article"); 
        $data =$a->select(); 
        $items = array();
        while(list($key,$val)= each($data)) { 
          $year = date("Y",strtotime($val["create_time"]));
          $month = date("m",strtotime($val["create_time"]));
         
            if(is_null($items[$year.$month])){
              $items[$year.$month]['year']=$year;
              $items[$year.$month]['month']=$month;
              $items[$year.$month]['count']=1;
            }else{

           $items[$year.$month]['count'] = $items[$year.$month]['count']+1;

            }
           
        } 
        $this->assign("items", $items);     
    	$this->display('Widget:essays');
    }
}